package com.wm;

/**
 * @ClassName:Main
 * @Description: 动态数组实现
 * @Author:Deamer
 * @Date:2022/1/2 21:41
 **/
public class Main {
    public static void main(String[] args) {
        ArrayList<Person> list = new ArrayList<>();
        list.add(new Person(1, "Jack"));
        list.add(new Person(2, "Rose"));
        list.add(new Person(2, "James"));
        list.remove(1);
        System.out.println(list.indexOf(new Person(1, "Jack")));
        ArrayList<Integer> list2 = new ArrayList<>();
        list2.add(11);
        list2.add(22);
        System.out.println(list2.indexOf(new Integer(22)));
    }

    private static void gcObjectTest() {
        ArrayList<Person> list = new ArrayList<>();
        list.add(new Person(1, "Jack"));
        list.add(new Person(2, "Rose"));
        list.add(new Person(2, "James"));
        list.clear();
        // 手动释放内存空间
        System.gc();
        System.out.println(list);
    }

    private static void test2() {
        // 测试扩容，将初始化容量改为2
        ArrayList<Person> list = new ArrayList<>();
        list.add(new Person(1, "Jack"));
        list.add(new Person(2, "Rose"));
        list.add(new Person(2, "James"));
        System.out.println(list);
    }

    private static void test1() {
        ArrayList list = new ArrayList();
        list.add(22);
        list.add(33);
        list.add(44);
        list.add(1, 11);
        list.remove(3);
        Asserts.test(list.get(2).equals(33));
        System.out.println(list.get(0));
        System.out.println(list);
    }
}
